package com.fz.us.admin.base.bean.search.page;

import com.fz.us.admin.base.bean.search.SearchEnum;
import com.fz.us.admin.base.bean.search.projection.Projection;

/**
 * 查询 - 参数 - Page
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-07-13 。
 * ============================================================================
 */
public abstract class Page {

    protected final SearchEnum.ResultType resultType;
    protected final Projection projection;

    protected Page(SearchEnum.ResultType resultType, Projection projection) {
        this.resultType = resultType;
        this.projection = projection;
    }

    public SearchEnum.ResultType getResultType() {
        return resultType;
    }

    public Projection getProjection() {
        return projection;
    }

    public abstract static class Builder<T extends Page, B extends Builder<T, B>> {

        private B theBuilder;

        protected SearchEnum.ResultType resultType;
        protected Projection projection;

        protected Builder () {
            theBuilder = getThis();
        }

        protected abstract B getThis();

        public B setResultType(SearchEnum.ResultType resultType) {
            this.resultType = resultType;
            return theBuilder;
        }

        public B setProjection(Projection projection) {
            this.projection = projection;
            return theBuilder;
        }

        public abstract T build();

    }

}
